package com.ruoyi.project.erp.so.controller;

import java.util.*;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.kuaidi.PropertiesReader;
import com.ruoyi.common.utils.kuaidi.SignUtils;
import com.ruoyi.framework.web.page.PageDomain;
import com.ruoyi.framework.web.page.TableSupport;
import com.ruoyi.project.erp.so.domain.QueryTrack;
import com.ruoyi.project.erp.so.domain.QueryTrackParam;
import com.ruoyi.project.erp.so.domain.QueryTrackReq;
import com.ruoyi.project.erp.sos.domain.Sos;
import com.ruoyi.project.erp.sos.service.ISosService;
import com.ruoyi.project.erp.sossend.domain.Sossend;
import com.ruoyi.project.erp.sossend.service.ISossendService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.erp.so.domain.So;
import com.ruoyi.project.erp.so.service.ISoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2020-08-24
 */
@Controller
@RequestMapping("/erp/so")
public class SoController extends BaseController
{
    private String prefix = "erp/so";

    @Resource
    private ISoService soService;
    @Resource
    private ISosService sosService;
    @Autowired
    private ISossendService sossendService;

    @RequiresPermissions("erp:so:view")
    @GetMapping()
    public String so()
    {
        return prefix + "/so";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("erp:so:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(So so)
    {
/*        PageDomain pageDomain = new PageDomain();
        pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM));
        pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE));
        pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN));
        pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC));*/
        Integer pageNum = ServletUtils.getParameterToInt(Constants.PAGE_NUM);
        Integer pageSize =ServletUtils.getParameterToInt(Constants.PAGE_SIZE);
        if(so.getUnSendqty() == 1){
            so.setSt("发货完成");
        }else if(so.getUnSendqty() == 0){
            so.setSt("保存,审核,发货中,收货完成,关闭");
        }
        if(EmptyUtils.isNotEmpty(so.getSt())){
            String extraIds = so.getSt();
            String sts ="";
            String[] extraIdArray = extraIds.split(",");
            for (String extraId : extraIdArray) {
                if (extraId != null && !"".equals(extraId)) {
                    sts += ",'" + extraId + "'";
                }
            }
            sts   =    "(" + sts.substring(1) + ")";
            so.setSt(sts);
        }
        List<So> list = soService.selectSoList(so);
        /*List<So> listUn = new ArrayList<>();
        for(So temp:list){
            if(!"发货完成".equals(temp.getSt()) && !"收货完成".equals(temp.getSt()) ){
                listUn.add(temp);
            }

        }*/
        List<So> resultList = new ArrayList<>();
        int totalPage = list.size()/pageSize+1;
        int count = pageNum*pageSize;
        if (pageNum == totalPage){
            count = list.size();
        }
        for(int start = (pageNum-1)*pageSize;start<count;start++){
            resultList.add(list.get(start));
        }
        for(So temp : resultList){
            System.out.println("id++++++++++++++++++++++"+temp.getId());
        }
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(0);
        rspData.setRows(resultList);
        rspData.setTotal(new PageInfo(list).getTotal());

        /*List<So> ll = (List<So>)rspData.getRows();
        for(So temp : ll){
            System.out.println("id------------------------"+temp.getId());
        }*/
        return rspData;
    }


    /**
     * PC端查询订单列表
     */
    @RequiresPermissions("erp:so:list")
    @PostMapping("/listAllSoOrder")
    @ResponseBody
    public TableDataInfo listAllSoOrder(@RequestBody So so)
    {
        Integer pageNum = 1;
        Integer pageSize = 10;
        List<So> list = soService.selectSoList(so);
        List<Map> resultList = new ArrayList<>();
        int totalPage = list.size()/pageSize+1;
        int count = pageNum*pageSize;
        if (pageNum == totalPage){
            count = list.size();
        }
        for(int start = (pageNum-1)*pageSize;start<count;start++){
            Map tempMap = new HashMap();
            tempMap.put("order",list.get(start));
            Sos temp = new Sos();
            temp.setMid(Long.parseLong(list.get(start).getId()));
            tempMap.put("orderDetail",sosService.selectSosList(temp));
            resultList.add(tempMap);
        }
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(0);
        rspData.setRows(resultList);
        rspData.setTotal(new PageInfo(list).getTotal());
        return rspData;
    }


    /**
     * 查询子列表
     */
    @RequiresPermissions("erp:so:list")
    @PostMapping("/listChild")
    @ResponseBody
    public TableDataInfo listChild(long mid,String unSendqty)
    {
            Sos sos = new Sos();
            sos.setMid(mid);
            List<Sos> childList = sosService.selectSosList(sos);
           List<Sos> resultList = new ArrayList<>();
           if("1".equals(unSendqty)){
               for(Sos temp:childList){
                   if(temp.getUnSendqty() ==0){
                       resultList.add(temp);
                   }
               }
            }else if ("0".equals(unSendqty)){
               for(Sos temp:childList){
                   if(temp.getUnSendqty() !=0){
                       resultList.add(temp);
                   }
               }
           }else{
               for(Sos temp:childList){
                       resultList.add(temp);
               }
           }

            TableDataInfo rspData = new TableDataInfo();
            rspData.setCode(0);
            rspData.setRows(resultList);
        return rspData;
    }

    /**
     * 查看详情
     */
    @RequiresPermissions("erp:so:list")
    @PostMapping("/listSoDetail")
    @ResponseBody
    public TableDataInfo listSoDetail(long id)
    {
        Sos sos = new Sos();
        sos.setMid(id);
        List<Sos> childList = sosService.selectSosList(sos);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(0);
        rspData.setRows(childList);
        return rspData;
    }

    /**
     * 手机端查询订单列表
     */
    @PostMapping("/listOrder")
    @ResponseBody
    public AjaxResult listOrder(@RequestBody So so,String permit)
    {
       //查询当前用户的权限
      /*  String[] emps = permit.split(",");
        List<So> resultList = new ArrayList<>();
        for(int i=0;i<emps.length;i++){
            so.setEmp(emps[i]);
            resultList.addAll(soService.selectSoList(so,p));
        }
        for(int j=0;j<resultList.size();j++){

        }*/
        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",soService.selectSoListPermit(so,permit));
    }

    /**
     * 手机端数据统计
     */
    @PostMapping("/listSoCount")
    @ResponseBody
    public AjaxResult listSoCount(@RequestBody So so,String beginTime,String endTime,String permit)
    {
        List<So> list = soService.selectSoListQuery(so,beginTime,endTime,permit);
        long[] mids = new long[list.size()];
        for(int i=0;i<list.size();i++){
            mids[i]=Long.parseLong(list.get(i).getId());
        }
        if(mids.length>0){
            return new AjaxResult(AjaxResult.Type.SUCCESS,"200",sosService.selectSosBymids(mids));
        }else{
            return error("暂无数据");
        }
    }

    /**
     * 手机端查询订单列表
     */
    @PostMapping("/listOrderQuery")
    @ResponseBody
    public AjaxResult listOrderQuery(@RequestBody So so,String beginTime,String endTime,String permit)
    {
        //查询当前用户的权限
       /* String[] emps = permit.split(",");
        List<So> resultList = new ArrayList<>();
        for(int i=0;i<emps.length;i++){
            so.setEmp(emps[i]);
            resultList.addAll(soService.selectSoListQuery(so,beginTime,endTime));
        }*/
        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",soService.selectSoListQuery(so,beginTime,endTime,permit));
    }
    /**
     * 手机端根据订单ID查询订单详情
     */
    @PostMapping("/listOrderDetail")
    @ResponseBody
    public AjaxResult listOrderDetail(long orderId)
    {
        Sos sos = new Sos();
        sos.setMid(orderId);
        List<Sos> list = sosService.selectSosList(sos);
        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("erp:so:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(So so)
    {
        if(EmptyUtils.isNotEmpty(so.getSt())){
            String extraIds = so.getSt();
            String sts ="";
            String[] extraIdArray = extraIds.split(",");
            for (String extraId : extraIdArray) {
                if (extraId != null && !"".equals(extraId)) {
                    sts += ",'" + extraId + "'";
                }
            }
            sts   =    "(" + sts.substring(1) + ")";
            so.setSt(sts);
        }
        List<So> list = soService.selectSoList(so);
        ExcelUtil<So> util = new ExcelUtil<So>(So.class);
        return util.exportExcel(list, "so");
    }

    /**
     * 导出主子列表
     */
    @RequiresPermissions("erp:so:export")
    @PostMapping("/exportAll")
    @ResponseBody
    public AjaxResult exportAll(So so)
    {
        if(EmptyUtils.isNotEmpty(so.getSt())){
            String extraIds = so.getSt();
            String sts ="";
            String[] extraIdArray = extraIds.split(",");
            for (String extraId : extraIdArray) {
                if (extraId != null && !"".equals(extraId)) {
                    sts += ",'" + extraId + "'";
                }
            }
            sts   =    "(" + sts.substring(1) + ")";
            so.setSt(sts);
        }
        so.setLogcode("");
        List<So> resultList = new ArrayList();
        List<So> list = soService.selectSoList(so);
        for(int i=0;i<list.size();i++){
            Sos sos = new Sos();
            sos.setMid(Long.parseLong(list.get(i).getId()));
            List<Sos> sosList = sosService.selectSosList(sos);
            for(int j=0;j<sosList.size();j++){
                //So temp = list.get(i);
                So temp = new So();
                temp.setId(list.get(i).getId());
                temp.setSt(list.get(i).getSt());
                temp.setFromwhname(list.get(i).getFromwhname());
                temp.setTowhname(list.get(i).getTowhname());
                temp.setCode(list.get(i).getCode());
                temp.setCreditdt(list.get(i).getCreditdt());
                temp.setCtype(list.get(i).getCtype());
                temp.setCreditemp(list.get(i).getCreditemp());
                temp.setDdate(list.get(i).getDdate());
                temp.setEmp(list.get(i).getEmp());
                temp.setLogcode(list.get(i).getLogcode());
                temp.setRecdt(list.get(i).getRecdt());
                temp.setRecemp(list.get(i).getRecemp());
                temp.setSenddt(list.get(i).getSenddt());
                temp.setSendemp(list.get(i).getSendemp());
                temp.setSendqty(list.get(i).getSendqty());

                temp.setShopname(list.get(i).getShopname());
                temp.setMemo(list.get(i).getMemo());
                temp.setSysdt(list.get(i).getSysdt());
                temp.setMcode(sosList.get(j).getMcode());
                if(sosList.get(j).getSmemo() != null){
                    temp.setSmemo(sosList.get(j).getSmemo());
                }
                temp.setPcode(sosList.get(j).getPcode());
                temp.setPname(sosList.get(j).getPname());
                temp.setPstd(sosList.get(j).getPstd());
                temp.setPunit(sosList.get(j).getPunit());
                temp.setQty(sosList.get(j).getQty());
                temp.setSendqty(sosList.get(j).getSendqty());
                temp.setUnSendqty(temp.getQty()-temp.getSendqty());
                resultList.add(temp);
            }
        }
        ExcelUtil<So> util = new ExcelUtil<So>(So.class);
        return util.exportExcel(resultList, "so");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("erp:so:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(So so)
    {
        return toAjax(soService.insertSo(so));
    }

    /**
     * 手机端新增保存
     */
    @PostMapping("/addOrder")
    @ResponseBody
    public AjaxResult addOrder(Date ddate,String emp,String ctype,String shop,String shopName,String towh,String towhname,@RequestBody JSONObject json)
    {
        List<Sos> sosList = json.getJSONArray("sosList").toJavaList(Sos.class);
        So so = new So();
        Long soId = Long.parseLong(IdWorker.getId());
        so.setId(soId.toString());
        so.setEmp(emp);
        so.setDdate(ddate);
        String mcode = OddUtil.createOdd("",soService.selectMaxCode());
        so.setCode(mcode);
        //so.setDdate(new Date());
        so.setCtype(ctype);
        so.setSt("保存");//0表示保存
        so.setShop(shop);
        so.setShopname(shopName);
        if("订货".equals(ctype)){
            //调拨出入
            so.setFromwh("1.01");
            so.setFromwhname("主仓");
            so.setTowh(shop);
            so.setTowhname(shopName);
        }
        if("退货".equals(ctype)){
            //调拨出入
            so.setTowh("1.01");
            so.setTowhname("主仓");
            so.setFromwh(shop);
            so.setFromwhname(shopName);
        }
        if("调货".equals(ctype)){
            //调拨出入
            so.setTowh(shop);
            so.setTowhname(shopName);
            so.setFromwh(towh);
            so.setFromwhname(towhname);
        }
        int num = soService.insertSo(so);
        if(num>0){
            for(int i=0;i<sosList.size();i++){
                Sos temp = sosList.get(i);
                temp.setMid(soId);
                temp.setMcode(mcode);
                temp.setSts("保存");
                sosService.insertSos(temp);
            }
        }
        return toAjax(num);
    }

    /**
     * 添加发货记录
     */
    @GetMapping("/addSosSend/{id}")
    public String addSosSend(@PathVariable("id") String id, ModelMap mmap)
    {
        Sos sos = sosService.selectSosById(Long.parseLong(id));
        mmap.put("sos", sos);
        return prefix + "/sossend";
    }

    /**
     * 修改
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        So so = soService.selectSoById(id);
        mmap.put("so", so);
        return prefix + "/edit";
    }

    /**
     * 修改sos
     */
    @GetMapping("/editSos/{id}")
    public String editSos(@PathVariable("id") String id, ModelMap mmap)
    {
        String idStr = String.valueOf(id);
        String pre = idStr.substring(0,2);
        if("11".equals(pre)){
            idStr = idStr.substring(2,idStr.length());
            //Long newId = Long.parseLong(idStr);
            So so = soService.selectSoById(idStr);
            mmap.put("so", so);
            return  "erp/so/edit";
        }else{
            idStr = idStr.substring(2,idStr.length());
            Long newId = Long.parseLong(idStr);
            Sos so = sosService.selectSosById(newId);
            mmap.put("sos", so);
            return  "erp/sos/edit";
        }
    }


    /**
     * 审批
     */
    @RequiresPermissions("erp:so:edit")
    @PostMapping("/reviewSo")
    @ResponseBody
    public AjaxResult reviewSo(String id)
    {
        So temp =new So();
        temp.setCreditemp(getSysUser().getF102());
        temp.setCreditdt(new Date());
        temp.setId(id);
        temp.setSt("审核");
        return toAjax(soService.updateSo(temp));
    }

    /**
     * 关闭
     */
    @RequiresPermissions("erp:so:edit")
    @PostMapping("/closeSo")
    @ResponseBody
    public AjaxResult closeSo(String id)
    {
        So temp =new So();
        temp.setId(id);
        temp.setSt("关闭");
        return toAjax(soService.updateSo(temp));
    }

    /**
     * 打开
     */
    @RequiresPermissions("erp:so:edit")
    @PostMapping("/openSo")
    @ResponseBody
    public AjaxResult openSo(String id)
    {
        int num =0;
        So temp =new So();
        temp.setId(id);
        //根据id获取订单信息
        So so = soService.selectSoById(id);
        //判断是否有发货信息
        Sossend sossend = new Sossend();
        sossend.setIds(Long.parseLong(id));
        List<Sossend> sossendList = sossendService.selectSossendList(sossend);
        if(sossendList.size()>0){
            //判断是否发货完成
            int sumSend =0;
           Sos sos = new Sos();
           sos.setMid(Long.parseLong(id));
           List<Sos> sosList = sosService.selectSosList(sos);
           int receiveNum =0;
           for(int i =0;i<sosList.size();i++){
               if("发货中".equals(sosList.get(i).getSts())){
                   temp.setSt("发货中");
                   num = soService.updateSo(temp);
                   break;
               }
               if("发货完成".equals(sosList.get(i).getSts())){
                   receiveNum++;
               }
           }
           if(receiveNum >=sosList.size()){
               temp.setSt("发货完成");
               num = soService.updateSo(temp);
           }
           //判断是否收货完成
            int recNum =0;
            for(int i=0;i<sossendList.size();i++){
                if("收货".equals(sossendList.get(i).getSt())){
                    recNum++;
                }
            }
            if(recNum >=sossendList.size()){
                temp.setSt("收货完成");
                num = soService.updateSo(temp);
            }
        }else{
            //没有发货信息，回到保存状态
            temp.setSt("保存");
            num = soService.updateSo(temp);
        }

       /* temp.setSt("审核");
        if(EmptyUtils.isEmpty(so.getCreditemp()) && EmptyUtils.isEmpty(so.getCreditdt())){
            temp.setCreditemp(getSysUser().getF102());
            temp.setCreditdt(new Date());
        }*/
        return toAjax(num);
    }

    /**
     * 撤销审批
     */
    @RequiresPermissions("erp:so:edit")
    @PostMapping("/disReviewSo")
    @ResponseBody
    public AjaxResult disReviewSo(String id)
    {
        //根据id获取施工单信息
        So so = soService.selectSoById(id);
        //判断撤销的时刻订单的状态
        So temp =new So();
        temp.setId(id);
        int num =0;
        if("审核".equals(so.getSt())){
           num = soService.disReviewSo(temp);
        }else if("发货中".equals(so.getSt())){
           num = soService.disReviewSoSend(temp);
        }
        return toAjax(num);
    }

    /**
     * 确认收货
     */
    @RequiresPermissions("erp:so:edit")
    @PostMapping("/receiveSo")
    @ResponseBody
    public AjaxResult receiveSo(String emp,String id)
    {
        So so = soService.selectSoById(id);
        if("发货中".equals(so.getSt())){
            So temp =new So();
            temp.setRecemp(emp);
            temp.setRecdt(new Date());
            temp.setId(id.toString());
            temp.setSt("收货");
            return toAjax(soService.updateSo(temp));
        }else{
            return  error("订单发货之后才能确认收货");
        }
    }

    /**
     * 发货
     */
    @RequiresPermissions("erp:so:edit")
    @PostMapping("/sendOrder")
    @ResponseBody
    public AjaxResult sendOrder(String emp,String id)
    {
        //判断当前订单是否已审批
        So so = soService.selectSoById(id);
        if("审核".equals(so.getSt())){
            So temp =new So();
            temp.setSendemp(getSysUser().getF102());
            temp.setSenddt(new Date());
            temp.setId(id.toString());
            temp.setSt("发货中");
            return toAjax(soService.updateSo(temp));
        }else{
            return  error("订单审核之后才能发货");
        }
    }


    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("erp:so:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(So so)
    {
        return toAjax(soService.updateSo(so));
    }

    /**
     * 删除【请填写功能名称】
     */
    //@RequiresPermissions("erp:so:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        //判断当前订单是否是保存状态
        So so = soService.selectSoById(ids);
        if(!"保存".equals(so.getSt())){
            return error("订单已审核，不能删除");
        }
        return toAjax(soService.deleteSoByIds(ids));
    }


    /**
     * 查询物流
     */
    @Log(title = "【查询物流】")
    @PostMapping( "/queryTrack")
    @ResponseBody
    public AjaxResult queryTrack(String taskNo)
    {
        String key = "BGRyDExR1339";
        String customer = "EB84262A6B7B846951FAD0FB98EE714F";
        String secret = "2b1d070d578a45b7b16b12c1d0580734";
        List<Map> resultList = new ArrayList<>();
        Map resultMap = new HashMap();
        Map<String,String> param = new HashMap<>();
        param.put("num",taskNo);
        param.put("key",key);
        String resultStr = HttpClientUtil.doGet("http://www.kuaidi100.com/autonumber/auto",param);
        //解析出comCode
        String[] map = resultStr.split(",");
        String[] com = map[1].split(":");
        String comCode = com[1].replaceAll("\"","");
        QueryTrack queryTrack = new QueryTrack();
        QueryTrackReq queryTrackReq = new QueryTrackReq();
        QueryTrackParam queryTrackParam = new QueryTrackParam();
        queryTrackParam.setCom(comCode);
        queryTrackParam.setNum(taskNo);
        queryTrackReq.setParam(queryTrackParam);
        queryTrackReq.setCustomer(customer);
        queryTrackReq.setSign(SignUtils.sign(new Gson().toJson(queryTrackParam)+key+customer));
        resultMap.put("com",comCode);
        resultMap.put("detail",queryTrack.queryTrack(queryTrackReq).getData());
        resultList.add(resultMap);
        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",resultList);
    }

    /**
     * 手机端查询发货列表
     */
    @PostMapping("/listSendOrder")
    @ResponseBody
    public AjaxResult listSendOrder(String id)
    {
       //查询所有的发货信息，去掉重复的
        List<Sossend> sossendList = sossendService.selectSossendSendCode(id);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(int i=0;i<sossendList.size();i++){
            Map temp = new HashMap();
            temp.put("sendcode",sossendList.get(i).getSendcode());
            temp.put("logcode",sossendList.get(i).getLogcode());
            temp.put("senddt",sossendList.get(i).getSenddt());
            temp.put("st",sossendList.get(i).getSt());
            //获取详细
            Sossend sossend = new Sossend();
            sossend.setSendcode(sossendList.get(i).getSendcode());
            List<Sossend> tempList = sossendService.selectSossendList(sossend);
            temp.put("detail",tempList);
            resultList.add(temp);
        }
        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",resultList);
    }

    /**
     * 手机端查询发货列表
     */
    @PostMapping("/listSendOrderAll")
    @ResponseBody
    public AjaxResult listSendOrderAll(String id){

        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",sossendService.selectSossendSendCode(id));
    }
    /**
     * 手机端查询发货详细
     */
    @PostMapping("/listSendOrderDetail")
    @ResponseBody
    public AjaxResult listSendOrderDetail(String sendCode){
        Sossend sossend = new Sossend();
        sossend.setSendcode(sendCode);
        List<Sossend> resultList = sossendService.selectSossendList(sossend);
        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",resultList);
    }

    /**
     * 手机端确认收货
     */
    @PostMapping("/ensureSt")
    @ResponseBody
    public AjaxResult ensureSt(String sendCode){
        Sossend sossend = new Sossend();
        sossend.setSendcode(sendCode);
        sossend.setSt("收货");
        int num = sossendService.updateSossendBatch(sossend);
        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",num);
    }

    /**
     * 更新金蝶信息
     */
    @PostMapping("/updateJDinfo")
    @ResponseBody
    public AjaxResult updateJDinfo(int type,String id)
    {
        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",soService.updateJDinfo(type, id));
    }
}
